<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp" %>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>部门</title>
    <script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";
    $(function (){
    	
        $("#empId").ligerComboBox({
            onBeforeOpen: selectUser, valueFieldID: 'empId',width:300
        });
        
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        if(viewType=="modify"){
        	 $("#deptId").attr("readonly", "readonly").removeAttr("validate");
        }
        
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);

    });
    
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + data.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("deptList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }

    function selectUser()
    {
    	dialog=$.ligerDialog.open({title: '选择用户',showMax: true, showToggle: true, showMin: true, isResize: true, modal: true,name:'winselector',width:600, height: 300, url: '${ctx}/user/toRadioUser'});
    }
    
    function callBackCancel(){
    	dialog.close();
    }
    
    function callBackOK(row){
   	 	var row;
       	$("#empId").val(row.userId);
        dialog.close();
   }
    
   
 </script>
</head>

<body style="padding:10px">
    <form name="mainform" method="post"  id="mainform" action="${ctx}/dept/save">
    <input type="hidden" name="viewType" value="${viewType}"/>
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 100%;">
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">部门编号:</td>
                <td align="left" class="l-table-edit-td" style="width:80px" >
                	<input type="text"  name="deptId" id="deptId" value="${command.deptId}" ltype="text" validate="{required:true,minlength:2,maxlength:50,notnull:true,remote:'${ctx}/dept/checkDeptId?oldDeptId=${command.deptId}'}"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">中文全称:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
	               <input type="text"  name="deptNameC" id="deptNameC" value="${command.deptNameC}" ltype="text" validate="{required:true,minlength:2,maxlength:50,notnull:true}"/>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">部门代码:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
                	<input type="text"  name="deptCode" id="deptCode" value="${command.deptCode}" ltype="text" validate="{required:true,minlength:2,maxlength:50,notnull:true}"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">英文全称:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
                	<input type="text" name="deptNameE" id="deptNameE" value="${command.deptNameE}" ltype="text" validate="{required:true,notnull:true}"/>
                </td>
                <td align="left"></td>
            </tr>
            
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">部门简称:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
                	<input type="text"  name="deptAbr" id="deptAbr" ltype="text" value="${command.deptAbr}" validate="{required:true,minlength:2,maxlength:50,notnull:true}"/>
                </td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">主管编号:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">
                	<input type="text" name="empId" id="empId"  value="${command.empId}" validate="{required:true,notnull:true}"/>
                </td>
                <td align="left"></td>
            </tr>
            
            <tr>
                <td align="left" class="l-table-edit-td" valign="top">部门类型</td>
                <td align="left" class="l-table-edit-td" style="width:160px">
                	 <select name="deptType" id="deptType" ltype="select" >
                	 	<c:forEach items="${deptTypes}" var="dt">
                	 		<c:choose>
                	 			<c:when test="${command.deptType eq  dt.id.tdId}">
                	 				<option value="${dt.id.tdId }" selected="selected">${dt.tdName }</option>
                	 			</c:when>
                	 			<c:otherwise>
                	 				<option value="${dt.id.tdId }">${dt.tdName }</option>
                	 			</c:otherwise>
                	 		</c:choose>
                	 		
                	 	</c:forEach>
                	 </select>
                </td>
                <td align="left"></td>
                <td align="left" class="l-table-edit-td">启用:</td>
                <td align="left" class="l-table-edit-td" style="width:160px" >
                	<c:choose>
                		<c:when test="${command.isEnable eq 'F' }">
                			<input id="isEnable" type="checkbox" name="isEnable" value="F" onchange="changeTnf(this)"/> 
                		</c:when>
                		<c:otherwise>
                			<input id="isEnable" type="checkbox" name="isEnable" value="T" checked="checked"  onchange="changeTnf(this)"/> 
                		</c:otherwise>
                	</c:choose>
                </td>
                <td align="left"></td>
            </tr>
            <tr>
                <td align="left" class="l-table-edit-td">备注:</td>
                <td align="left" class="l-table-edit-td"> 
                <textarea cols="100" rows="3" class="l-textarea" id="remark" name="remark" style="width:400px">${command.remark }</textarea>
                </td> <td align="left"></td>
           </tr>
           <tr>
                <td align="left" class="l-table-edit-td" valign="top">建档人:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">${command.userCre }</td>
                <td align="left"></td>
                
                <td align="left" class="l-table-edit-td" valign="top">修改人:</td>
                <td align="left" class="l-table-edit-td" style="width:80px">${command.userUpd }</td>
                <td align="left"></td>
           </tr>
        </table>
    </form>
</body>
</html>
